<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>弹窗</title>
    <script src="__PUBLIC__/Admin/js/jquery.min.js"></script>
    <script src="__PUBLIC__/Admin/js/jquery.form.js"></script>
    <!-- <link rel="stylesheet" href="__PUBLIC__/Admin/css/font-awesome.min93e3.css"> -->
    <link rel="stylesheet" href="__PUBLIC__/Admin/css/bootstrap-grid.min.css">
    <link rel="stylesheet" href="__PUBLIC__/Admin/css/bootstrap-reboot.min.css">
    <link rel="stylesheet" href="__PUBLIC__/Admin/css/bootstrap.css">
    <script src="__PUBLIC__/Admin/js/bootstrap.bundle.min.js"></script>
    <script src="__PUBLIC__/Admin/js/bootstrap.min.js"></script>
    <script src="__PUBLIC__/Common/layer/layer.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/Admin/css/style.css">
    <script src="__PUBLIC__/Admin/js/script.js"></script>
    <style>
    .btn-list{
   display: block;
    text-align: center;
    margin: auto;
    width: 500px;
    }
    #submit{
        width: 160px;
        margin: 30px auto 0 auto;
        display: block;
    }
    </style>
</head>
<body>
<!-- <form class="lay" action="" method="post" id=""> -->
<style>
    .bu{
        font-size: 15px;
        color: red;
    }
    .zbt,.xbt{
        display: none;
    }
</style>
    <div class="head-title">
        <div>庄 <span class="bu" >补<input type="checkbox" name="zb" class="bu_input"></span></div>
        <div>闲 <span class="bu" >补<input type="checkbox" name="xb" class="bu_input"></span></div>
    </div>
    <div class="content">
        <div class="fl zhu">
            <table class="table" style="background-color:rgba(0, 0, 0, 0.05);">
                <thead>
                <tr>
                    <th>1</th>
                    <th>2</th>
                    <th class="zbt">3</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>
                        <div class="select select1">
                            <select class="list list-s1">
                                <option value="黑">黑</option>
                                <option value="红">红</option>
                                <option value="花">花</option>
                                <option value="片">片</option>
                            </select>
                        </div>
                        <div class="select select2">
                            <select class="list list-s2">
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                            <option value="6">6</option>
                            <option value="7">7</option>
                            <option value="8">8</option>
                            <option value="9">9</option>
                            <option value="10">10</option>
                            <option value="J">J</option>
                            <option value="Q">Q</option>
                            <option value="K">K</option>
                            <option value="A">A</option>
                        </select>
                        </div>
                    </td>
                    <td>
                        <div class="select select3">
                            <select class="list list-s1">
                                <option value="红">红</option>
                                <option value="黑">黑</option>
                                <option value="花">花</option>
                                <option value="片">片</option>
                            </select>
                        </div>
                        <div class="select select4">
                            <select class="list list-s2">
                                <option value="2">2</option>
                                <option value="3">3</option>
                                <option value="4">4</option>
                                <option value="5">5</option>
                                <option value="6">6</option>
                                <option value="7">7</option>
                                <option value="8">8</option>
                                <option value="9">9</option>
                                <option value="10">10</option>
                                <option value="J">J</option>
                                <option value="Q">Q</option>
                                <option value="K">K</option>
                                <option value="A">A</option>
                                <option value=""></option>
                            </select>
                        </div>
                    </td>
                    <td class="zbt">
                        <div class="select select5">
                            <select class="list list-s1">
                                <option value="黑">黑</option>
                                <option value="红">红</option>
                                <option value="花">花</option>
                                <option value="片">片</option>
                            </select>
                        </div>
                        <div class="select select6">
                            <select class="list list-s2">
                                <option value=""></option>
                                <option value="2">2</option>
                                <option value="3">3</option>
                                <option value="4">4</option>
                                <option value="5">5</option>
                                <option value="6">6</option>
                                <option value="7">7</option>
                                <option value="8">8</option>
                                <option value="9">9</option>
                                <option value="10">10</option>
                                <option value="J">J</option>
                                <option value="Q">Q</option>
                                <option value="K">K</option>
                                <option value="A">A</option>

                            </select>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="fr xin">
            <table class="table" style="background-color:rgba(0, 0, 0, 0.05);">
                <thead>
                <tr>
                    <th>1</th>
                    <th>2</th>
                    <th class="xbt">3</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>
                        <div class="select select7">
                            <select class="list list-s1">
                                <option value="黑">黑</option>
                                <option value="红">红</option>
                                <option value="花">花</option>
                                <option value="片">片</option>
                            </select>
                        </div>
                        <div class="select select8">
                            <select class="list list-s2">
                                <option value="2">2</option>
                                <option value="3">3</option>
                                <option value="4">4</option>
                                <option value="5">5</option>
                                <option value="6">6</option>
                                <option value="7">7</option>
                                <option value="8">8</option>
                                <option value="9">9</option>
                                <option value="10">10</option>
                                <option value="J">J</option>
                                <option value="Q">Q</option>
                                <option value="K">K</option>
                                <option value="A">A</option>
                            </select>
                        </div>
                    </td>
                    <td>
                        <div class="select select9">
                            <select class="list list-s1">
                                <option value="红">红</option>
                                <option value="黑">黑</option>
                                <option value="花">花</option>
                                <option value="片">片</option>
                            </select>
                        </div>
                        <div class="select select10">
                            <select class="list list-s2">
                                <option value="2">2</option>
                                <option value="3">3</option>
                                <option value="4">4</option>
                                <option value="5">5</option>
                                <option value="6">6</option>
                                <option value="7">7</option>
                                <option value="8">8</option>
                                <option value="9">9</option>
                                <option value="10">10</option>
                                <option value="J">J</option>
                                <option value="Q">Q</option>
                                <option value="K">K</option>
                                <option value="A">A</option>
                            </select>
                        </div>
                    </td>
                    <td class="xbt">
                        <div class="select select11">
                            <select class="list list-s1">
                                <option value="黑">黑</option>
                                <option value="红">红</option>
                                <option value="花">花</option>
                                <option value="片">片</option>
                            </select>
                        </div>
                        <div class="select select12">
                            <select class="list list-s2">
                                <option value=""></option>
                                <option value="2">2</option>
                                <option value="3">3</option>
                                <option value="4">4</option>
                                <option value="5">5</option>
                                <option value="6">6</option>
                                <option value="7">7</option>
                                <option value="8">8</option>
                                <option value="9">9</option>
                                <option value="10">10</option>
                                <option value="J">J</option>
                                <option value="Q">Q</option>
                                <option value="K">K</option>
                                <option value="A">A</option>
                            </select>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="btn-list">
        <label class="radio-inline dejiang" style="color:red; ">和 庄对 闲对</label>
    </div>
    <div class="submit-container">
        <!--<button type="button" id="chaxun" class="btn btn-outline-success">查询</button>-->
        <button type="submit" id="submit" istype="0" class="btn btn-outline-success">提交</button>
    </div>
<!-- </form> -->
<script>
    //是否补第三张牌
    $(".bu_input").change(function(){
        console.log('aaa');
        di3zhang();
    } );
    //显示隐藏第三张拍
    function di3zhang() {
        //庄
        if ($("input[name='zb']").is(':checked')){
            $('.zbt').show();//显示
        }else{
            $('.zbt').hide();
        }
        //闲
        if ($("input[name='xb']").is(':checked')){
            $('.xbt').show();//显示
        }else{
            $('.xbt').hide();
        }
    }
    $(".list").change(function(){
        chaxun();
    } );
    //判断结果
    function chaxun(){
        var type=$('#submit').attr('istype');
        var list_s1 = $('.select1 option:selected').text();
        var list_s2 = $('.select2 option:selected').text();
        var list_s3 = $('.select3 option:selected').text();
        var list_s4 = $('.select4 option:selected').text();
        var list_s5 = $('.select5 option:selected').text();
        var list_s6 = $('.select6 option:selected').text();
        var list_s7 = $('.select7 option:selected').text();
        var list_s8 = $('.select8 option:selected').text();
        var list_s9 = $('.select9 option:selected').text();
        var list_s10 = $('.select10 option:selected').text();
        var list_s11 = $('.select11 option:selected').text();
        var list_s12 = $('.select12 option:selected').text();



        if ($("input[name='zb']").is(':checked')){
            $zhuang=[
                [list_s1, list_s2],
                [list_s3, list_s4],
                [list_s5, list_s6]
            ];
        }else{
            $zhuang=[
                [list_s1, list_s2],
                [list_s3, list_s4],
            ];
        }
        if ($("input[name='xb']").is(':checked')){
            $xian=[
                [list_s7, list_s8],
                [list_s9, list_s10],
                [list_s11, list_s12]
            ];
        }else{
            $xian=[
                [list_s7, list_s8],
                [list_s9, list_s10],
            ];
        }
        var txt = {
            "庄":  $zhuang,
            "闲": $xian
        };
        $.ajax({
            url: "/Admin/Hold/chaxun",
            type: "post",
            cache: false,
            data: {
                type: type,
                txt:JSON.stringify(txt)
            },
            dataType: "json",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            success: function (req) {
                console.log(req);
                $('.dejiang').html(req['data']);


            },
            //请求出错处理。注意：有差错时才执行程序体，才会出现alert弹框
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                // alert('错了339');
                console.log('错了339');
            },
        })
    }
    // console.log(window.location)
    //录入结果
    $('#submit').click(function () {
        var period_number = getQueryString("period_number");
        var type=$('#submit').attr('istype');
        var list_s1 = $('.select1 option:selected').text();
        var list_s2 = $('.select2 option:selected').text();
        var list_s3 = $('.select3 option:selected').text();
        var list_s4 = $('.select4 option:selected').text();
        var list_s5 = $('.select5 option:selected').text();
        var list_s6 = $('.select6 option:selected').text();
        var list_s7 = $('.select7 option:selected').text();
        var list_s8 = $('.select8 option:selected').text();
        var list_s9 = $('.select9 option:selected').text();
        var list_s10 = $('.select10 option:selected').text();
        var list_s11 = $('.select11 option:selected').text();
        var list_s12 = $('.select12 option:selected').text();
        var chk_value = [];
        var radio = $('input:radio:checked').val();
        $('input[name="optradio3"]:checked').each(function () {
            chk_value.push($(this).val());
        });
        if (radio == null) {
            if (chk_value.length == 0) {
                var a = []
            } else if (chk_value.length == 1) {
                var a = [chk_value[0]]
            } else {
                var a = [chk_value[0], chk_value[1]]
            }
        } else {
            if (chk_value.length == 0) {
                var a = [radio]
            } else if (chk_value.length == 1) {
                var a = [radio, chk_value[0]]
            } else {
                var a = [radio, chk_value[0], chk_value[1]]
            }
        }


        if ($("input[name='zb']").is(':checked')){
            $zhuang=[
                [list_s1, list_s2],
                [list_s3, list_s4],
                [list_s5, list_s6]
            ];
        }else{
            $zhuang=[
                [list_s1, list_s2],
                [list_s3, list_s4],
            ];
        }
        if ($("input[name='xb']").is(':checked')){
            $xian=[
                [list_s7, list_s8],
                [list_s9, list_s10],
                [list_s11, list_s12]
            ];
        }else{
            $xian=[
                [list_s7, list_s8],
                [list_s9, list_s10],
            ];
        }
        var txt = {
            "庄":  $zhuang,
            "闲": $xian
        };
        $.ajax({
            url: "/Admin/Hold/enter",
            type: "post",
            cache: false,
            data: {
                period_number:period_number,
                type: type,
                award_numbers:JSON.stringify(a), //开奖结果
                txt:JSON.stringify(txt)
            },
            dataType: "json",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            success: function (req) {
                console.log(req.msg)
                if(req.msg == '录入成功'){
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    window.parent.location.reload()
                    parent.layer.close(index);

                }

            },
            //请求出错处理。注意：有差错时才执行程序体，才会出现alert弹框
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                // alert('a')
                console.log('a');
            },
        })
    });

    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        console.log(r);
        if (r != null) return unescape(r[2]);
        return null;
    }
</script>
</body>
</html>